using System.Globalization;
using Meebey.SmartIrc4net;

namespace Thunder.Irc.Formatter.Default
{
    /// <summary>
    /// Handles the Error message 
    /// </summary>
    internal class MessageFormatterChannelAction : MessageFormatter
    {
        /// <summary>
        /// Gets the type of message handled by the parser
        /// </summary>
        public override ReceiveType MessageType
        {
            get { return ReceiveType.ChannelAction; }
        }

        /// <summary>
        /// This method is invoked when the resource image path is being resolved
        /// </summary>
        /// <returns>A string containing the path to the image</returns>
        protected override string GetImagePathCore()
        {
            return @"/Thunder.IrcClient;component/Content/Images/Editor/Action.png";
        }

        /// <summary>
        /// This method is invoked when a message should be formatted
        /// </summary>
        /// <param name="args">The <see cref="CancelMessageFormattingEventArgs"/> containing the message to be passed</param>
        /// <remarks>You can cancel further processing of the message by setting the <see cref="CancelMessageFormattingEventArgs.Cancel"/> to true</remarks>
        protected override void FormatCore(CancelMessageFormattingEventArgs args)
        {
            string message = args.Message.Remove(0, 7);
            message = string.Format(CultureInfo.InvariantCulture, @"<Span Foreground=""#FFB200FF"">{0} {1}</Span>", args.MessageData.Nick, message);

            args.Message = message;
        }
    }
}